from validation import *

# FIELD REQUIRED CHECK

v = Validation()
v.addField('username', '', [
	REQUIRED()
])

try:
	v.run()
except ValidationExceptions, e:
	print e.exceptions

# EMAIL CHECK

v = Validation()
v.addField('email', 'test', [
	REQUIRED(),
	EMAIL(message='{value} is not a valid email address')
])

try:
	v.run()
except ValidationExceptions, e:
	print e.exceptions

# NUMBER CHECK, numRange=[1, 150] => inclusive 1 and 150. numRange[None, 150] => maximum of 150, etc.

v = Validation()
v.addField('age', '-1', [
	REQUIRED(),
	NUMBER(message='{name} must be between 1 and 150. "{value}" is out of range.', numRange=[1, 150])
])

try:
	v.run()
except ValidationExceptions, e:
	print e.exceptions